#include "head.h"
//写好的模板tcp连接文件 这个是用户端   连接之后用户端自动发消息  服务端接收到回复消息
int main() {
    int sockfd = socket(AF_INET, SOCK_STREAM, 0);
    struct sockaddr_in server_addr;
    memset(&server_addr, 0, sizeof(server_addr));
    char buff[100];

    server_addr.sin_family = AF_INET;
    server_addr.sin_port = htons(8888);
    server_addr.sin_addr.s_addr = inet_addr("192.168.250.100");

    int connect_fd = connect(
            sockfd, (struct sockaddr *) &server_addr, sizeof(server_addr)
    );
    printf("连接服务器成功\n");
    for (int i = 0; i < 100; i++) {
        size_t res = write(sockfd, "hello ", 10);
        memset(buff,0, sizeof(buff));
        read(sockfd, buff, sizeof(buff));
        printf("连接fd::%d sockfd::%d 发送hello的字节:%ld 服务器返回信息::%s\n", connect_fd, sockfd, res,buff);
        // sleep(100);
        getchar();
    }
    close(connect_fd);
    close(sockfd);
}